home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11476 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: solon.com!not-for-mail
  2. From: thads@csn.net (Thad Smith)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated
  4. Subject: Re: const pointer confusion...
  5. Date: 24 Mar 1996 11:41:47 -0600
  6. Organization: T3 Systems
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4j41gr$nje@solutions.solon.com>
  10. References: <4j06gm$7oa@solutions.solon.com>
  11. Reply-To: ThadSmith@acm.org
  12. NNTP-Posting-Host: solutions.solon.com
  13.  
  14. In article <4j06gm$7oa@solutions.solon.com>,
  15. "Reed R. Mangino" <mangino@planet.net> wrote:
  16. >Could someone please straighten me out on this:
  17. >
  18. >1) const int *p = 10;
  19. >    p is a constant pointer to an int, right? While p can be made to
  20. >    point to something else, *p can never be assigned to, right?
  21. >
  22. >2) int *const p;
  23. >    p is a pointer to an integer.  *p can be assigned to, but p can
  24. >    never be made to point to another address in memory, right?
  25. >
  26. >3) int const *p;
  27. >    What the heck is this?  I can't find anything like this in my 
  28. >    books, but my compiler thinks everything is hunky doory!???
  29.  
  30. It is the same as 
  31.     const int *p;
  32. Standard C allows storage class specifiers (extern, static, register,
  33. etc.), type qualifiers (const, volatile), and type specifiers to be
  34. placed in any order, although placing storage class specifiers other
  35. than at the beginning is considered obsolescent.  The location of
  36. "const" relative to asterisks is significant, but relative to type
  37. declaration is not.
  38.  
  39. Thad
  40.